﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sjt_console20200528
{
    class GoodComparer : IComparer<Good>
    {
        /// <summary>
        /// 比较x和y的大小： 返回负值：x小于y；返回0：x=y；返回正值：x大于y
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public int Compare(Good x, Good y)
        {
            // 默认返回值
            int i = 0;
            // x小于y
            if (x == null && y != null)
            {

                i = -1;
            }
            // x大于y
            if (x != null && y == null)
            {
                i = 1;
            }

                if (x != null && y != null)
            {
                // 比较大小
                i = x.GoodGrade - y.GoodGrade;
            }
           

            return i*-1;
        }
    }
}
